package com.yuwubao.hz_International.util;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.jetbrains.annotations.NotNull;

/**
 * Created by xiwang on 2/13/17.
 */
@ApiModel(value = "baseResult",description = "返回")
public class RestApiResponse<T> {
    /**
     * 状态信息
     */
    @ApiModelProperty(value = "返回信息")
    private String message;
    /**
     * 状态码
     */
    @ApiModelProperty(value = "返回状态")
    private int status;

    /**
     * 结果
     */
    @ApiModelProperty(value = "返回数据")
    private T result;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void updateStatusMessage(int status, String msg) {
        this.setMessage(msg);
        this.setStatus(status);
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    /**
     * 成功之后的返回
     *
     * @param status
     * @param result
     */
    public void successResponse(int status, T result) {
        this.status = status;
        this.result = result;
    }

    /**
     * 成功之后的返回
     *
     * @param status
     * @param result
     */
    public void successResponse(int status, T result,String mess) {
        this.status = status;
        this.result = result;
        this.message = mess;
    }

   public void successResponse(T result){
        this.status = Const.SUCCESS;
        this.result = result;
   }
    /**
     * 失败之后的返回
     *
     * @param message
     * @param status
     */
    public void failedApiResponse(int status, String message) {
        this.message = message;
        this.status = status;
    }

    public void failedApiResponse(String msg) {
        this.status = Const.FAILED;
        this.message = msg;
    }
}
